*
* Multithreading: This function is *not* MT safe; only one transaction can be
* active at a time.
+ *
+ * This function takes a shared lock on the @self repository.
*/
gboolean
ostree_repo_prepare_transaction (OstreeRepo *self,
memset (&self->txn.stats, 0, sizeof (OstreeRepoTransactionStats));
+ self->txn_locked = ostree_repo_lock_push (self, OSTREE_REPO_LOCK_SHARED,
+ cancellable, error);
+ if (!self->txn_locked)
+ return FALSE;
+
self->in_transaction = TRUE;
if (self->min_free_space_percent > 0)
{
if (!ot_ensure_unlinked_at (self->repo_dir_fd, "transaction", 0))
return FALSE;
+ if (self->txn_locked)
+ {
+ if (!ostree_repo_lock_pop (self, cancellable, error))
+ return FALSE;
+ self->txn_locked = FALSE;
+ }
+
if (out_stats)
*out_stats = self->txn.stats;
self->in_transaction = FALSE;
+ if (self->txn_locked)
+ {
+ if (!ostree_repo_lock_pop (self, cancellable, error))
+ return FALSE;
+ self->txn_locked = FALSE;
+ }
+
return TRUE;
}